package com.jzh.eurekaconsumerfeign.controller;

import com.jzh.eurekaconsumerfeign.service.UploadFileClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

@Controller
public class UploadController {
    @Autowired
    private UploadFileClient uploadFileClient;
    @PostMapping(value = "/uploadFile", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    @ResponseBody
    public String handleFileUpload(@RequestParam(value = "xiaomi",required = false)String xiaomi,@RequestParam(value = "file") MultipartFile file) {
        return uploadFileClient.handleFileUpload(xiaomi,file);
    }
    @PostMapping(value = "/uploadFiles", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    @ResponseBody
    public String handleFilesUpload(@RequestParam(value = "xiaomi",required = false)String xiaomi,@RequestParam(value = "files") MultipartFile[] files) {
        return uploadFileClient.handleFilesUpload(xiaomi,files);
    }
}
